package com.um.jdy.platform.sharing.controller;

import com.um.jdy.common.charge.enums.OrderEnum;
import com.um.jdy.platform.sharing.entity.dto.RecordsPageDTO;
import com.um.jdy.platform.sharing.manager.SharingRecordsManager;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.TokenRequired;
import com.um.springboot.starter.orm.controller.BaseController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.params.PageParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分账管理
 *
 * @author 邓南辉
 * 日期 2023/5/11
 * 版权所有 广州优匠科技有限公司
 */
@RestController
@RequestMapping("/api/v1/cms/sharing/records")
@Api(tags = "分账记录")
@ApiPermission("sharing_records")
@TokenRequired
public class SharingRecordsController extends BaseController<SharingRecordsManager>{

    /**
     * 分页查询充电订单列表
     * @param params
     * @return
     */
    @ApiPermission("page")
    @ApiOperation("分页查询")
    @PostMapping("/page")
    public Response getSharingRecordsPage(@RequestBody RecordsPageDTO params){

        PageParams pageParams = params.toPageParams(
                new String[]{"orderNo","outTradeNo","nickname","mobile"},
                new String[]{"o.order_no","o.out_trade_no","u2.nickname","u2.mobile"},
                "o.create_time","beginTime","endTime");

        pageParams.getCondition().put("o.status",OrderEnum.Status.Completed.name());

        return manager.getSharingRecordsPage(pageParams);
    }

}
